#include"TcpClientMediator.h"
#include"TcpClient.h"
TcpClientMediator::TcpClientMediator()
{
	m_pNet = new TcpClient(this);
}
TcpClientMediator::~TcpClientMediator()
{
	if (m_pNet) {
		delete m_pNet;
		m_pNet = nullptr;
	}
}


//打开网络
bool TcpClientMediator::OpenNet()
{
	if (!m_pNet->InitNet())
	{
		return false;
	}
	return true;
}

//关闭网络
void TcpClientMediator::CloseNet()
{
	m_pNet->UnInitNet();
}

//发送数据
bool TcpClientMediator::SendData(long ISendIp, char* buf, int nLen)
{
	if (!m_pNet->SendData(ISendIp, buf, nLen))
	{
		return false;
	}
	return true;
}

//处理数据
#include<iostream>
void TcpClientMediator::DealData(long ISendIp, char* buf, int nLen)
{
	//把数据传给kernel类
    Q_EMIT SIG_ReadyData(ISendIp,buf,nLen);
}

